/*
 * @Author      : ZhouQiJun
 * @Date        : 2025-07-18 01:11:51
 * @LastEditors : ZhouQiJun
 * @LastEditTime: 2025-07-20 12:03:38
 * @Description : 导航类
 */
import { Page } from '@playwright/test'
import HelperBase from './HelperBase'

export default class NavigationTo extends HelperBase {
  constructor(page: Page) {
    super(page)
  }

  async formLayoutsPage() {
    //await this.page.getByText('Forms').click()
    await this.selectGroupItem('Forms')
    await this.page.getByText('Form Layout').click()
    await this.waitFor(2)
  }

  async datePickerPage() {
    //await this.page.getByText('Forms').click()
    await this.selectGroupItem('Forms')
    await this.page.getByText('DatePicker').click()
  }

  private async selectGroupItem(menuStr: string) {
    const menu = this.page.getByTitle(menuStr)
    const expandedState = await menu.getAttribute('aria-expanded')
    if (expandedState === 'false') await menu.click()
  }
}
